const { jwtVerify } = require("../../shared");
const { HttpAuthException } = require("../util/HttpException");

exports.authMiddleware = async function(req, res, next) {
    const token = req.headers.authorization;
    try {
        const data = jwtVerify(token);
        req.user = data;
        next();
    } catch (e) {
        next(new HttpAuthException);
    }
}